import dayjs from 'dayjs';

function formatTime(time: any):any {
    let arr: any[] = [];
    time = time.toLocaleDateString();
    time.replace(/\d+/g, (val: any) => {
        val = val < 2 ? `0${val}` : val;
        arr.push(val);
    });
    return arr;
}

function formatDateTime (value:string, formatter : string = 'YYYY-MM-DD HH:mm'):any {
    if (!value) return '';
    return dayjs(value).format(formatter);
};

export default {
    formatTime,
    formatDateTime
};